home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
bfmt139.zip
/
BFMT139.DOC
< prev
next >
Wrap
Text File
|
1993-04-28
|
13KB
|
506 lines
BFMT.EXE ----------------------------------------------------
This program is free and you are welcome to use it at your own
risk. If you pass it on please give this accompanying document as
well.
Also if you do use it, or a modified form of it, please acknowledge
the original author: Brendan Babb.
If you modify, improve upon, or have suggestions for this program
Please email me (Brendan@micro.uct.ac.za).
-----------------------------------------------------------------
BFMT.EXE - text formatting
What can bfmt do ?
* align text
* format paragraphs - centre
- left
- right
- justified
- unchanged
* inherit whitespace or specify whitespace
* embedded formatting options in the text
What does it work on?
* bfmt is really designed for use with vi like editors
such as elvis
* you can bfmt any text file from the command line
by 'TYPE {filename} | BFMT [options] [>{filename}]'
or 'BFMT [options] <{input} >{output}'
/-----------------------------------------------------------------
How do I use BFMT ?
You can use the program from either the command line or from
within an editor like elvis. From the command line if you run
'BFMT' input will be taken from the keyboard and outputed to
the screen. This isnt particularly useful but with
redirection you can save text entered and/or input from a
file.
For example 'BFMT >output.txt' will take whatever you type as
input and save the output to the file output.txt. It will
save whatever text entered (until you type ^Z) in formatted
form in the file output.txt. Similarly 'BFMT <input.txt
>output.txt' will take text from input.txt and save it in
output.txt. Alternatively 'TYPE input.txt | >>output.txt' will
take input.txt as input and append the output to the file
output.txt.
If you use vi-like editors (elvis) you can map various
options to different keys. I've mapped '!}BFMT -fl' to Alt-L
and '!}BFMT -fj' to Alt-J etc. These mappings format the
text from the cursor's line through till the end of the
current paragraph. See the examples below for what the
various options on formatting actually are.
A few notes: bfmt thinks in words, lines and paragraphs. So
separate paragraphs with blank lines, or lines beginning with
paragraph markers. Otherwise specify the option to treat each
line as a separate paragraph. Bfmt works by collecting as
many words as it can before it reaches a new paragraph. These
words and the last input line are passed to formatting
functions. If a line beginning with a paragraph marker is
found, then that line is saved to a parameter buffer. This
buffer is dealt with after formatting and output, so that only
subsequent paragraphs are affected by it.
/-----------------------------------------------------------------
Option Summary
-? display options and defaults
-a{0|1} all lines treated as paragraphs or not
-f{a|c|l|r|j|u} format type
note that -fa indents c/c++ text for you
-h display options and defaults
-i{0|1} inherit whitespace or not
-m{number} minimum number of words to format in justify
-s{number} amount of whitespace when -i0
-t{0|1} to follow text embedded options
the following options are recognised
-a, -w, -f, -i, -k, -s, -h (current defaults), -w
-v display version
-w{number} right margin
-{{list} list of paragraph identifiers (for recognizing
text embedded options)
-({list} list of sentence markers (gets a forced double space
afterwards)
-u save the options previously listed on command line
as the defaults.
? display options and defaults
/------------------- EXAMPLES -----------------
The following are examples of bfmt in action. All the examples
use the text below as their input. I ran bfmt from elvis 1.7
by using the following command
:r !bfmt <sample [options]
This looks rather messy, but the output looks neater!
-------> begin sample text
// ------------- Sample text. ---------------
#define
// practice c
main () {
sample com1
com2
for (int i = ; ; ) {
do this
do that
do nothing
}
wait around and make mistakes
}
// practice text
This is sample test.
This is sample test.
This is sample test.
line two
line three
And more sample text.
.-w50 -fr
with still even more text to use ansd reuse
blah blah blah blah hi world bye world
Last line.
// -------------------------------------- ----------------
---------> end sample text
Example 1 : BFMT
In this example, the defaults as supplied are used. All text
is assumed to be paragraphs. As many words as possible are
crammed into each line. Note that the embedded commands are
obeyed to produce a right format paragraph.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do that do
nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is
sample test. line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 2 : BFMT -t0
In this example bfmt is told not obey options embedded in the
text itself (ie -w50 -fr). The last paragraph is no longer
right formatted.
----------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do that do
nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is
sample test. line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd reuse blah blah blah
blah hi world bye world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 3 : BFMT -i0
Here, BFMT is told not to inherit whitespace, but to use the
default -s{} setting (8). Notice that the lines beginning with /
are still aligned to the very left. This is because BFMT has
been told ( -{ ) to see / as a paragraph marker.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do
that do nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is sample test.
line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 4. : BFMT -a1
Each line is assumed to be a separate paragraph here. The
affect is that any lines that are too long will be chopped
into two lines and white space within a line is reduced to
single spaces.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () {
sample com1
com2
for (int i = ; ; ) {
do this
do that
do nothing
}
wait around and make mistakes
}
// practice text
This is sample test.
This is sample test.
This is sample test.
line two
line three
And more sample text.
.-w50 -fr
wi